{% load avatar_tags i18n %}

<script type="text/template" id="side-nav-tmpl">
    <a href="#" title="{% trans "Close" %}" aria-label="{% trans "Close" %}" class="sf2-icon-x1 sf-popover-close op-icon hidden-md-up js-close-side-nav fright"></a>
    <h3 class="hd">{% trans "System Admin" %}</h3>
    <ul class="side-tabnav-tabs">

        {% if user.admin_permissions.can_view_system_info %}
        <li class="tab<% if (cur_tab == 'dashboard') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#dashboard/"><span class="sf2-icon-info"></span>{% trans "Info" %}</a>
        </li>
        {% endif %}

        {% if is_pro and user.admin_permissions.can_view_statistic %}
        <li class="tab">
            <a href="{% url "sys_statistic_file" %}"><span class="sf2-icon-histogram"></span>{% trans "Statistic" %}</a>
        </li>
        {% endif %}

        {% if is_default_admin %}
        <li class="tab<% if (cur_tab == 'devices') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#desktop-devices/"><span class="sf2-icon-monitor"></span>{% trans "Devices" %}</a>
        </li>
        {% endif %}

        {% if constance_enabled and user.admin_permissions.can_config_system %}
        <li class="tab">
            <a href="{% url "sys_settings" %}"><span class="sf2-icon-cog2"></span>{% trans "Settings" %}</a>
        </li>
        {% endif %}

        {% if user.admin_permissions.can_manage_library %}
        <li class="tab<% if (cur_tab == 'libraries') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#all-libs/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a>
        </li>
        {% endif %}

        {% if user.admin_permissions.can_manage_user %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/useradmin/"><span class="sf2-icon-user"></span>{% trans "Users" %}</a>
        </li>
        {% endif %}

        {% if user.admin_permissions.can_manage_group %}
        <li class="tab<% if (cur_tab == 'groups') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#groups/"><span class="sf2-icon-group"></span>{% trans "Groups" %}</a>
        </li>
        {% endif %}

        {% if is_pro and user.admin_permissions.can_manage_group %}
        <li class="tab<% if (cur_tab == 'address-book') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#address-book/"><span class="sf2-icon-organization"></span>{% trans "Departments" context "address book" %}</a>
        </li>
        {% endif %}

        {% if multi_tenancy and is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/orgadmin/"><span class="sf2-icon-organization"></span>{% trans "Organizations" %}</a>
        </li>
        {% endif %}

        {% if multi_institution and is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/instadmin/"><span class="sf2-icon-organization"></span>{% trans "Institutions" %}</a>
        </li>
        {% endif %}

        {% if is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/notificationadmin/"><span class="sf2-icon-msgs"></span>{% trans "Notifications" %}</a>
        </li>
        {% endif %}

        {% if is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/publinkadmin/"><span class="sf2-icon-link"></span>{% trans "Links" %}</a>
        </li>
        {% endif %}

        {% if sysadmin_extra_enabled and user.admin_permissions.can_view_user_log %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/loginadmin/"><span class="sf2-icon-clock"></span>{% trans "Logs" %}</a>
        </li>
        {% endif %}

        {% if events_enabled and is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/virus_scan_records/"><span class="sf2-icon-security"></span>{% trans "Virus Scan" %}</a>
        </li>
        {% endif %}

        {% if enable_guest_invitation and is_default_admin %}
        <li class="tab">
        <a href="{{ SITE_ROOT }}sys/invitationadmin/"><span class="sf2-icon-invite"></span>{% trans "Invitations" %}</a>
        </li>
        {% endif %}

        {% if enable_terms_and_conditions and is_default_admin %}
        <li class="tab">
            <a href="{{ SITE_ROOT }}sys/termsadmin/"><span class="sf2-icon-wiki"></span>{% trans "Terms and Conditions" %}</a>
        </li>
        {% endif %}

        {% if is_pro and user.admin_permissions.can_view_admin_log %}
        <li class="tab<% if (cur_tab == 'admin-logs') { %> tab-cur<% } %>">
            <a href="{{ SITE_ROOT }}sysadmin/#admin-operation-logs/"><span class="sf2-icon-admin-log"></span>{% trans "Admin Logs" %}</a>
        </li>
        {% endif %}

    </ul>
    <% if (cur_tab == 'libraries') { %>
        <% if (option == 'all') { %>
            <form action="{{ SITE_ROOT }}sysadmin/#search-libs/" method="get" class="side-search-form" id="libs-search-form">
                <input type="text" name="name" class="input" value="" placeholder="{% trans "Search libraries by name..." %}" title="{% trans "Search libraries by name..." %}" aria-label="{% trans "Search libraries by name..." %}" />
            </form>
        <% } %>
        <% if (option == 'trash') { %>
            <form action="{{ SITE_ROOT }}sysadmin/#search-trash-libs/" method="get" class="side-search-form" id="trash-libs-search-form">
                <input type="text" name="name" class="input" value="" placeholder="{% trans "Search libraries by owner..." %}" title="{% trans "Search libraries by owner..." %}" aria-label="{% trans "Search libraries by owner..." %}" />
            </form>
        <% } %>
    <% } %>
    <% if (cur_tab == 'groups') { %>
        <form action="{{ SITE_ROOT }}sysadmin/#search-groups/" method="get" class="side-search-form" id="groups-search-form">
            <input type="text" name="name" class="input" value="" placeholder="{% trans "Search groups by name..." %}" title="{% trans "Search groups by name..." %}" aria-label="{% trans "Search groups by name..." %}" />
        </form>
    <% } %>
</script>

<script type="text/template" id="sysinfo-tmpl">
    <div class="header-bar">
        <h3 class="">{% trans "Info" %}</h3>
    </div>
    <div class="sysinfo">
    </div>
    <span class="loading-icon loading-tip"></span>
</script>

<script type="text/template" id="sysinfo-con-tmpl">
    <dl>
        <dt>{% trans "System Info" %}</dt>
        <dd>
            <% if (is_pro) { %>
                {% trans "Professional Edition" %}
                <% if (with_license) { %>
                    {% trans "licensed to" %} <%- license_to %>,
                    <% if (license_mode == 'lifetime') { %>
                        {% trans "upgrade service expired in" %} <%- license_expiration %>
                    <% } else { %>
                        {% trans "expires on" %} <%- license_expiration %>
                    <% } %>
                <% } %>

                <% if (app.pageOptions.is_default_admin) { %>
                <div class="license-file-upload">
                    <button type="button" class="license-file-upload-btn">{% trans "Upload licence" %}</button>
                    <input type="file" name="license" class="license-file-upload-input hide" />
                </div>
                <% } %>

            <% } else { %>
            {% trans "Community Edition" %}
            <a href="http://manual.seafile.com/deploy_pro/migrate_from_seafile_community_server.html" target="_blank">{% trans "Upgrade to Pro Edition" %}</a>
            <% } %>
        </dd>

        <dt>{% trans "Libraries" %} / {% trans "Files" %}</dt>
        <dd><%- repos_count %> / <%- total_files_count %></dd>

        <dt>{% trans "Storage Used" %}</dt>
        <dd><%- formatted_storage %></dd>

        <dt>{% trans "Total Devices" %} / {% trans "Current Connected Devices" %}</dt>
        <dd><%- total_devices_count %> / <%- current_connected_devices_count %></dd>

        <% if (is_pro) { %>
        <dt>{% trans "Activated Users" %} / {% trans "Total Users" %} / {% trans "Limits" %}</dt>
        <dd>
            <%- active_users_count %>
            /
            <%- users_count %>
            /
            <% if (with_license) { %>
                <%- license_maxusers %>
            <% } else { %>
                --
            <% } %>
        </dd>
        <% } else { %>
        <dt>{% trans "Activated Users" %} / {% trans "Total Users" %}</dt>
        <dd>
            <%- active_users_count %>
            /
            <%- users_count %>
        </dd>
        <% } %>

        <dt>{% trans "Groups" %}</dt>
        <dd><%- groups_count %></dd>

        <% if (multi_tenancy_enabled) { %>
        <dt>{% trans "Organizations" %}</dt>
        <dd><%- org_count %></dd>
        <% } %>
    </dl>
</script>

<script type="text/template" id="devices-tmpl">
    <div class="hd ovhd">
        <ul class="tab-tabs-nav fleft">
            <li class="tab <% if (cur_tab == 'desktop') { %> ui-state-active <% } %>">
                <a href="#desktop-devices/" class="a">{% trans "Desktop" %}</a>
            </li>
            <li class="tab <% if (cur_tab == 'mobile') { %> ui-state-active <% } %>">
                <a href="#mobile-devices/" class="a">{% trans "Mobile" %}</a>
            </li>
            <% if (is_pro) { %>
            <li class="tab <% if (cur_tab == 'errors') { %> ui-state-active <% } %>">
                <a href="#device-errors/" class="a">{% trans "Errors" %}</a>
            </li>
            <% } %>
            <% if (app.pageOptions.is_pro & app.pageOptions.enable_limit_ipaddress) { %>
            {% include "trusted_ip/sysadmin-templates_tab.html" %}
            <% } %>
        </ul>
    </div>
    <table class="hide">
        <thead>
            <tr>
                <th width="22%">{% trans "User" %}</th>
                <th width="17%">{% trans "Platform" %} / {% trans "Version" %}</th>
                <th width="22%">{% trans "Device Name" %}</th>
                <th width="17%">{% trans "IP" %}</th>
                <th width="17%">{% trans "Last Access" %}</th>
                <th width="5%"></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <span class="loading-icon loading-tip"></span>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No connected devices" %}</h2>
    </div>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
</script>

<script type="text/template" id="device-item-tmpl">
    <td><%- user %></td>
    <td><%- platform %> / <%- client_version %></td>
    <td><%- device_name %></td>
    <td><%- last_login_ip %></td>
    <td><time title='<%- time %>'><%- time_from_now %></time></td>
    <td>
        <div>
            <span class="unlink-device op-icon sf2-icon-delete vh" title="{% trans "Unlink" %}"></span>
        </div>
    </td>
</script>

<script type="text/template" id="device-errors-tmpl">
    <div class="hd">
        <ul class="tab-tabs-nav fleft">
            <li class="tab <% if (cur_tab == 'desktop') { %> ui-state-active <% } %>">
                <a href="#desktop-devices/" class="a">{% trans "Desktop" %}</a>
            </li>
            <li class="tab <% if (cur_tab == 'mobile') { %> ui-state-active <% } %>">
                <a href="#mobile-devices/" class="a">{% trans "Mobile" %}</a>
            </li>
            <li class="tab <% if (cur_tab == 'errors') { %> ui-state-active <% } %>">
                <a href="#device-errors/" class="a">{% trans "Errors" %}</a>
            </li>
            <% if (app.pageOptions.is_pro & app.pageOptions.enable_limit_ipaddress) { %>
            {% include "trusted_ip/sysadmin-templates_tab.html" %}
            <% } %>
        </ul>
        <button id="clean-device-errors" class="fright hide"><span class="vam">{% trans "Clean" %}</span></button>
    </div>
    <table class="hide">
        <thead>
            <tr>
                <th width="15%">{% trans "User" %}</th>
                <th width="17%">{% trans "Device" %} / {% trans "Version" %}</th>
                <th width="18%">{% trans "IP" %}</th>
                <th width="15%">{% trans "Library" %}</th>
                <th width="17%">{% trans "Error" %}</th>
                <th width="18%">{% trans "Time" %}</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <span class="loading-icon loading-tip"></span>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No sync errors" %}</h2>
    </div>
</script>

<script type="text/template" id="device-error-item-tmpl">
    <td>
        <a href="{{ SITE_ROOT }}useradmin/info/<%- email %>/"><%- email %></a>
    </td>
    <td><%- device_name %> / <%- client_version %></td>
    <td><%- device_ip %>
    <td>
        <a href="{{ SITE_ROOT }}sysadmin/#libs/<%= repo_id %>/"><%- repo_name %></a>
    </td>
    <td><%- error_msg %></td>
    <td><time title='<%- time %>'><%- time_from_now %></time></td>
</script>

{% include "trusted_ip/sysadmin-templates_trusted_ip.html" %}

<script type="text/template" id="user-info-popup-tmpl">
    <div class="outer-caret up-outer-caret"><div class="inner-caret"></div></div>
    <div class="sf-popover-con">
        <div class="item ovhd">
            {% avatar request.user 36 %}
            <div class="txt">
                <%- app.pageOptions.name %><br />
                <%- app.pageOptions.contact_email %>
            </div>
        </div>
        <div class="loading-icon loading-tip"></div>
        <p class="error alc hide"></p>
        <div id="space-traffic" class="hide"></div>
        <a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
        <a href="{{ SITE_ROOT }}" title="{% trans "Exit admin panel" %}" class="item">{% trans "Exit admin panel" %}</a>
        <a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
    </div>
</script>

<script type="text/template" id="confirm-dialog-with-extra-option-tmpl">
    <h3 id="dialogTitle"><%= title %></h3>
    <p><%= content %></p>
    <% if (is_pro) { %>
    <p>
        <label class="checkbox-label">
            <input type="checkbox" name="confirm-extra-option" id="confirm-extra-option" class="vam" />
            <span class="checkbox-option vam"><%= extraOption %></span>
        </label>
    </p>
    <% } %>
</script>

<script type="text/template" id="libraries-tabnav-tmpl">
    <div class="tabnav ovhd">
        <ul class="tabnav-tabs fleft">
            <li class="tabnav-tab<% if (cur_tab == 'all') { %> tabnav-tab-cur<% } %>">
                <a href="#all-libs/">{% trans "All" %}</a>
            </li>
            <li class="tabnav-tab<% if (cur_tab == 'system') { %> tabnav-tab-cur<% } %>">
                <a href="#system-lib/">{% trans "System" %}</a>
            </li>
            <li class="tabnav-tab<% if (cur_tab == 'trash') { %> tabnav-tab-cur<% } %>">
                <a href="#trash-libs/">{% trans "Trash" %}</a>
            </li>
        </ul>
        <% if (cur_tab == 'trash') { %>
        <button class="js-clean fright hide">{% trans "Clean" %}</button>
        <% } %>
        <% if (cur_tab == 'all') { %>
        <button class="js-add-library fright">{% trans "New Library" %}</button>
        <% } %>
    </div>
</script>

<script type="text/template" id="libraries-tmpl">
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="4%"><!--icon--></th>
                <th width="34%">{% trans "Name" %}</th>
                <th width="13%">{% trans "Files / Size" %}</th>
                <th width="19%">ID</th>
                <th width="20%">{% trans "Owner" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No libraries" %}</h2>
    </div>
</script>

<script type="text/template" id="library-add-form-tmpl">
    <form id="library-add-form" action="" method="post" class="hide">{% csrf_token %}
        <h3 id="dialogTitle">{% trans "New Library" %}</h3>
        <label for="library-name">{% trans "Name" %}</label><br />
        <input type="text" name="library_name" value="" class="input" id="library-name" /><br />
        <label for="library-owner">{% trans "Owner" %}</label>
        <span class="tip">{% trans "(If left blank, owner will be admin)" %}</span><br />
        <input type="hidden" name="library_owner" value="" id="library-owner" />
        <p class="error hide"></p>
        <input type="submit" class="submit" value="{% trans "Submit" %}" />
    </form>
</script>

<script type="text/template" id="search-libraries-tmpl">
    <h3>{% trans "Search Library"%}</h3>
    <form id="search-repo-form" method="get" action="">
        <p class="tip">{% trans "Tip: you can search by keyword in name or owner or both." %}</p>
        <label>{% trans "Name" %}</label><br />
        <input type="text" name="name" class="input" value=""/><br />
        <label>{% trans "Owner" %}</label><br />
        <input type="text" name="owner" class="input" value=""/><br />
        <input type="submit" value="{% trans "Submit" %}" class="submit" />
    </form>
    <h3>{% trans "Result"%}</h3>
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="4%"><!--icon--></th>
                <th width="34%">{% trans "Name" %}</th>
                <th width="13%">{% trans "Files / Size" %}</th>
                <th width="19%">ID</th>
                <th width="20%">{% trans "Owner" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No libraries" %}</h2>
    </div>
</script>

<script type="text/template" id="library-item-tmpl">
    <td>
        <img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
    </td>
    <% if (name) { %>
        <% if (enable_sys_admin_view_repo && is_pro && !encrypted) { %>
        <td><a href="#libs/<%= id %>/"><%- name %></a></td>
        <% } else { %>
        <td><%- name %></td>
        <% } %>
    <% } else { %>
    <td>--</td>
    <% } %>
    <td><%= file_count %> / <%= size_formatted %></td>
    <td style="font-size:11px;"><%= id %></td>
    <td>
        <% if (owner.indexOf('@seafile_group') == -1) { %>
        <a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a>
        <% } else { %>
        <a href="{{ SITE_ROOT }}sysadmin/#address-book/groups/<% print(owner_name); %>/"><%- group_name %></a>
        <% } %>
    </td>
    <td>
        <% if (owner && owner.indexOf('@seafile_group') == -1) { %>
        <a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
        <a href="#" class="sf2-icon-move sf2-x repo-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
        <div class="sf-dropdown sf-dropdown-inline">
            <a href="#" class="sf2-icon-caret-down more-op-icon op-icon vh sf-dropdown-toggle" title="{% trans "More Operations" %}" aria-label="{% trans "More Operations" %}"></a>
            <ul class="hidden-op repo-hidden-op hide sf-dropdown-menu">
                <% if (!encrypted) { %>
                <li><a class="op js-repo-share" href="#">{% trans "Share" %}</a></li>
                <% } %>
                <li><a class="op js-popup-history-setting" href="#">{% trans "History Setting" %}</a></li>
            </ul>
        </div>
        <% } %>
    </td>
</script>

<script type="text/template" id="system-library-tmpl">
    <table class="hide">
        <thead>
            <tr>
                <th width="25%">{% trans "Name" %}</th>
                <th width="35%">ID</th>
                <th width="40%">{% trans "Description" %}</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <span class="loading-icon loading-tip"></span>
</script>

<script type="text/template" id="system-library-item-tmpl">
    <td><a href="#libs/<%= id %>/"><%- name %></a></td>
    <td style="font-size:11px;"><%= id %></td>
    <td><%= description %></td>
</script>

<script type="text/template" id="trash-libraries-tmpl">
    <span class="loading-icon loading-tip"></span>
    <p class="tip hide">{% trans "Tip: libraries deleted 30 days ago will be cleaned automatically."%}</p>
    <table class="hide">
        <thead>
            <tr>
                <th width="5%"><!--icon--></th>
                <th width="40%">{% trans "Name" %}</th>
                <th width="25%">{% trans "Owner" %}</th>
                <th width="20%">{% trans "Deleted Time" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No library deleted yet" %}</h2>
    </div>
</script>

<script type="text/template" id="trash-library-item-tmpl">
    <td>
        <img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
    </td>
    <td><%- name %></td>
    <td>
        <% if (owner.indexOf('@seafile_group') == -1) { %>
        <a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a>
        <% } else { %>
        <%- group_name %>
        <% } %>
    </td>
    <td><time title="<%= time %>"><%= time_from_now %></time></td>
    <td>
        <a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
        <a href="#" class="sf2-icon-reply sf2-x repo-restore-btn op-icon vh" title="{% trans "Restore" %}" aria-label="{% trans "Restore" %}"></a>
    </td>
</script>

<script type="text/template" id="dir-view-tmpl">
    <div class="repo-file-list-topbar">
        <p class="path-bar"></p>
        <div class="repo-op"></div>
    </div>
    <div class="js-dir-content">
        <table class="repo-file-list">
            <thead>
                <tr>
                    <th width="5%"><!--icon--></th>
                    <th width="50%">{% trans "Name" %}</th>
                    <th width="10%"></th>
                    <th width="15%">{% trans "Size" %}</th>
                    <th width="20%">{% trans "Last Update" %}</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </div>
    <span class="loading-icon loading-tip"></span>
    <p class="error hide"></p>
</script>

<script type="text/template" id="dir-path-bar-tmpl">
    <% if (is_system_library) { %>
    <a href="#system-lib/" class="path-link normal">{% trans "System" %}</a>
    <% } else { %>
    <a href="#all-libs/" class="path-link normal">{% trans "All" %}</a>
    <% } %>
    <span class="path-split">/</span>
    <% if (path == '/') { %>
        <%- repo_name %>
    <% } else { %>
        <a href="#libs/<%= repo_id %>/" class="path-link normal"><%- repo_name %></a>
        <span class="path-split">/</span>
        <% for (var i = 0, len = path_list.length - 1; i < len; i++) { %>
        <a href="#libs/<%= repo_id %>/<% print(path_list_encoded.slice(0, i+1).join('/')); %>" class="path-link normal"><%- path_list[i] %></a>
        <span class="path-split">/</span>
        <% } %>
        <%- path_list[i] %>
    <% } %>
</script>

<script type="text/template" id="dir-op-bar-tmpl">
    <div id="basic-upload" class="inline-block">
        <button class="op-btn basic-upload-btn" >{% trans "Upload" %}</button>
        <input id="basic-upload-input" class="hide" type="file" name="file" multiple />
    </div>
    <button id="add-new-dir" class="op-btn">{% trans "New Folder" %}</button>
</script>

<script type="text/template" id="dirent-item-tmpl">
    <td><img src="<%= icon_url %>" width="24" alt="" /></td>
    <% if (is_file) { %>
    <td><%- obj_name %></td>
    <% } else { %>
    <td><a href="<%= url %>"><%- obj_name %></a></td>
    <% } %>
    <td>
        <% if (is_system_library) { %>
        <a href="#" class="sf2-icon-delete sf2-x dirent-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
        <% } %>
        <% if (is_file) { %>
        <a href="#" class="sf2-icon-download sf2-x dirent-download-btn op-icon vh" title="{% trans "Download" %}" aria-label="{% trans "Download" %}"></a>
        <% } %>
    </td>
    <td><%= file_size %></td>
    <td><time title="<%= time %>"><%= time_from_now %></time></td>
</script>

<script type="text/template" id="library-transfer-form-tmpl">
    <form method="" action="" id="repo-transfer-form">
        <h3><%= title %></h3>
        <input type="hidden" name="email" /><br />
        <p class="error hide"></p>
        <input type="submit" value="{% trans "Submit" %}" />
    </form>
</script>

<script type="text/template" id="groups-tmpl">
    <div class="hd ovhd">
        <h3 class="fleft">{% trans "Groups" %}</h3>
        <div class="fright">
            <button class="btn-white js-add-group">{% trans "New Group" %}</button>
            <button class="btn-white js-export-excel">{% trans "Export Excel" %}</button>
        </div>
    </div>
    <span class="loading-icon loading-tip"></span>
    <table>
        <thead>
            <tr>
                <th width="35%">{% trans "Name" %}</th>
                <th width="30%">{% trans "Owner" %}</th>
                <th width="25%">{% trans "Created At" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No groups" %}</h2>
    </div>
    <p class="error error-tip hide"></p>
</script>

<script type="text/template" id="search-groups-tmpl">
    <h3>{% trans "Search Group"%}</h3>
    <form id="search-group-form" method="get" action="">
        <p class="tip">{% trans "Tip: you can search by keyword in name." %}</p>
        <label>{% trans "Name" %}</label><br />
        <input type="text" name="name" class="input" value=""/><br />
        <input type="submit" value="{% trans "Submit" %}" class="submit" />
    </form>
    <h3>{% trans "Result"%}</h3>
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="35%">{% trans "Name" %}</th>
                <th width="30%">{% trans "Owner" %}</th>
                <th width="25%">{% trans "Created At" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No groups" %}</h2>
    </div>
</script>

<script type="text/template" id="group-add-form-tmpl">
    <form id="group-add-form" action="" method="post" class="hide">{% csrf_token %}
        <h3 id="dialogTitle">{% trans "New Group" %}</h3>
        <label for="group-name">{% trans "Name" %}</label><br />
        <input type="text" name="group_name" value="" class="input" id="group-name" /><br />
        <label for="group-owner">{% trans "Owner" %}</label>
        <span class="tip">{% trans "(If left blank, owner will be admin)" %}</span><br />
        <input type="hidden" name="group_owner" value="" id="group-owner" />
        <p class="error hide"></p>
        <input type="submit" class="submit" value="{% trans "Submit" %}" />
    </form>
</script>

<script type="text/template" id="group-item-tmpl">
    <td>
        <% if (parent_group_id == 0) { %>
        <a href="{{ SITE_ROOT }}sysadmin/#groups/<%= id %>/libs/"><%- name %></a>
        <% } else { %>
        <a href="{{ SITE_ROOT }}sysadmin/#address-book/groups/<%= id %>/"><%- name %></a>
        <% } %>
    </td>
    <td>
        <% if (owner != 'system admin') { %>
        <a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a>
        <% } else { %>
        --
        <% } %>
    </td>
    <td><time title="<%= time %>"><%= time_from_now %></time></td>
    <td>
        <% if (owner != 'system admin') { %>
        <a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
        <a href="#" class="sf2-icon-move sf2-x group-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
        <% } %>
    </td>
</script>

<script type="text/template" id="group-transfer-form-tmpl">
    <form method="" action="" id="group-transfer-form">
        <h3><%= title %></h3>
        <input type="hidden" name="email" /><br />
        <p class="error hide"></p>
        <input type="submit" value="{% trans "Submit" %}" />
    </form>
</script>

<script type="text/template" id="folder-perm-item-tmpl">
<% if (for_user) { %>
<td>
    <a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(user_email)); %>/" target="_blank"><%- user_name %></a>
</td>
<% } else { %>
<td>
    <a href="{{ SITE_ROOT }}sysadmin/#groups/<%= group_id %>/libs/" target="_blank"><%- group_name %></a>
</td>
<% } %>
<td>
    <div class="perm">
        <span>
        <% if (is_pro && is_admin) { %>
            {% trans "Admin" %}
        <% } else { %>
            <% if (permission == 'rw') { %>
                {% trans "Read-Write" %}
            <% } else { %>
                {% trans "Read-Only" %}
            <% } %>
        <% } %>
        </span>
        <a href="#" title="{% trans "Edit" %}" class="perm-edit-icon sf2-icon-edit op-icon vh"></a>
    </div>
    <select class="perm-toggle-select select-white hide w100">
        <% if (is_pro) { %>
            <% if (is_admin) { %>
                <option value="rw">{% trans "Read-Write" %}</option>
                <option value="r">{% trans "Read-Only" %}</option>
                <option value="admin" selected="selected">{% trans "Admin" %}</option>
            <% } else { %>
                <% if (permission == 'rw') { %>
                    <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                    <option value="r">{% trans "Read-Only" %}</option>
                    <option value="admin">{% trans "Admin" %}</option>
                <% } else { %>
                    <option value="rw">{% trans "Read-Write" %}</option>
                    <option value="r" selected="selected">{% trans "Read-Only" %}</option>
                    <option value="admin">{% trans "Admin" %}</option>
                <% } %>
            <% } %>
        <% } else { %>
            <% if (permission == 'rw') { %>
                <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                <option value="r">{% trans "Read-Only" %}</option>
            <% } else { %>
                <option value="rw">{% trans "Read-Write" %}</option>
                <option value="r" selected="selected">{% trans "Read-Only" %}</option>
            <% } %>
        <% } %>
    </select>
</td>
<td>
    <a href="#" class="sf2-icon-delete delete-icon op-icon vh" title="{% trans "Delete" %}"></a>
</td>
</script>

<script type="text/template" id="share-popup-tmpl">
<h3 class="hd" id="dialogTitle"><%= title %></h3>
<div id="share-tabs" class="nav-con-tabs">
    <ul class="nav-con-tabs-nav">
        <li class="tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
        <li class="tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
    </ul>

    <div class="nav-con-tabs-content">
        <span class="loading-icon loading-tip"></span>
        <div id="dir-user-share" class="tabs-panel">
            <table>
                <thead>
                <tr>
                    <th width="55%">{% trans "User" %}</th>
                    <th width="30%">{% trans "Permission" %}</th>
                    <th width="15%"></th>
                </tr>
                </thead>
                <tbody>
                <tr id="add-dir-user-share-item">
                    <td>
                        <input type="hidden" name="emails" class="w100" />
                    </td>
                    <td>
                        <select name="permission" class="share-permission-select w100">
                            <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                            <option value="r">{% trans "Read-Only" %}</option>
                            <% if (is_pro) { %>
                                <option value="admin">{% trans "Admin" %}</option>
                            <% } %>
                        </select>
                    </td>
                    <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                </tr>
                </tbody>
            </table>
            <p class="error hide"></p>
        </div>

        <div id="dir-group-share" class="tabs-panel hide">
            <table>
                <thead>
                <tr>
                    <th width="55%">{% trans "Group" %}</th>
                    <th width="30%">{% trans "Permission" %}</th>
                    <th width="15%"></th>
                </tr>
                </thead>
                <tbody>
                <tr id="add-dir-group-share-item">
                    <td>
                        <input type="groups" name="groups" class="w100" />
                    </td>
                    <td>
                        <select name="permission" class="share-permission-select w100">
                            <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                            <option value="r">{% trans "Read-Only" %}</option>
                            <% if (is_pro) { %>
                                <option value="admin">{% trans "Admin" %}</option>
                            <% } %>
                        </select>
                    </td>
                    <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                </tr>
                </tbody>
            </table>
            <p class="error hide"></p>
        </div>
    </div>
</div>
</script>

<script type="text/template" id="groups-tabnav-tmpl">
    <p class="path-bar">
        <a class="normal" href="#groups/">{% trans "Groups" %}</a>
        <span class="path-split">/</span>
    </p>
    <div class="tabnav ovhd">
        <ul class="tabnav-tabs fleft">
            <li class="tabnav-tab<% if (cur_tab == 'libs') { %> tabnav-tab-cur<% } %>">
                <a href="#groups/<%= group_id %>/libs/">{% trans "Libraries" %}</a>
            </li>
            <li class="tabnav-tab<% if (cur_tab == 'members') { %> tabnav-tab-cur<% } %>">
                <a href="#groups/<%= group_id %>/members/">{% trans "Members" %}</a>
            </li>
        </ul>
        <% if (cur_tab == 'members') { %>
        <div class="fright">
            <button id="js-add-group-member">{% trans "Add Member" %}</button>
        </div>
        <% } %>
    </div>
</script>

<script type="text/template" id="add-group-member-form-tmpl">
    <form id="add-group-member-form" action="" method="post" class="hide">{% csrf_token %}
        <h3 id="dialogTitle">{% trans "Add Member" %}</h3>
        <label for="email">{% trans "Email" %}</label><br />
        <input type="text" name="email" value="" id="email" /><br />
        <p class="error hide"></p>
        <input type="submit" class="submit" value="{% trans "Submit" %}" />
    </form>
</script>

<script type="text/template" id="group-libraries-tmpl">
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="4%"><!--icon--></th>
                <th width="35%">{% trans "Name" %}</th>
                <th width="20%">{% trans "Size" %}</th>
                <th width="26%">{% trans "Shared By" %}</th>
                <th width="15%">{% trans "Operations" %}</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No libraries" %}</h2>
    </div>
</script>

<script type="text/template" id="group-library-item-tmpl">
    <td>
        <img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
    </td>
    <td>
        <% if (enable_sys_admin_view_repo && is_pro && !encrypted) { %>
        <a href="#libs/<%= repo_id %>/"><%- name %></a>
        <% } else { %>
        <%- name %>
        <% } %>
    </td>
    <td><%- formatted_size %></td>
    <td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(shared_by)); %>/"><%- shared_by %></a></td>
    <td>
        <a href="#" class="sf2-icon-delete sf2-x repo-unshare-btn op-icon vh" title="{% trans "Unshare" %}" aria-label="{% trans "Unshare" %}"></a>
    </td>
</script>

<script type="text/template" id="group-members-tmpl">
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="5%"></th>
                <th width="25%">{% trans "Name" %}</th>
                <th width="35%">{% trans "Email" %}</th>
                <th width="25%">{% trans "Role" %}</th>
                <th width="10%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No members" %}</h2>
    </div>
</script>

<script type="text/template" id="group-member-item-tmpl">
    <td><img src="<%= avatar_url %>" alt="" width="20" class="avatar" /></td>
    <td><%- name %></td>
    <td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(email)); %>/"><%- email %></a></td>
    <td>
        <% if (role == 'Owner') { %>
        <span class="cur-role">{% trans "Owner" %}</span>
        <% } else if (role == 'Admin') { %>
        <span class="cur-role">{% trans "Admin" %}</span>
        <span title="{% trans "Edit" %}" class="user-role-edit-icon sf2-icon-edit op-icon vh"></span>
        <select name="role" class="user-role-select hide">
            <option value="0">{% trans "Member" %}</option>
            <option value="1" selected="selected">{% trans "Admin" %}</option>
        </select>
        <% } else if (role == 'Member') { %>
        <span class="cur-role">{% trans "Member" %}</span>
        <span title="{% trans "Edit" %}" class="user-role-edit-icon sf2-icon-edit op-icon vh"></span>
        <select name="role" class="user-role-select hide">
            <option value="0" selected="selected">{% trans "Member" %}</option>
            <option value="1">{% trans "Admin" %}</option>
        </select>
        <% } %>
    </td>
    <td>
        <% if (role != 'Owner') { %>
        <a href="#" class="sf2-icon-delete sf2-x member-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
        <% } %>
    </td>
</script>

<script type="text/template" id="admin-operation-logs-tmpl">
    <div class="hd ovhd">
        <ul class="tab-tabs-nav fleft">
            <li class="tab ui-state-active">
                <a href="#admin-operation-logs/" class="a">{% trans "Admin Operation Logs" %}</a>
            </li>
            <li class="tab">
                <a href="#admin-login-logs/" class="a">{% trans "Admin Login Logs" %}</a>
            </li>
        </ul>
    </div>
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="20%">{% trans "Email" %}</th>
                <th width="15%">{% trans "Operation" %}</th>
                <th width="50%">{% trans "Detail" %}</th>
                <th width="15%">{% trans "Time" %}</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No Admin Operation Logs" %}</h2>
    </div>
</script>

<script type="text/template" id="admin-log-item-tmpl">
    <td><a href="<%= admin_user_url %>"><%- email %></a></td>
    <td><%= op_title %></td>
    <td><%= op_details %></td>
    <td><time title="<%- time %>"><%- time_from_now %></time></td>
</script>

<script type="text/template" id="admin-login-logs-tmpl">
    <div class="hd ovhd">
        <ul class="tab-tabs-nav fleft">
            <li class="tab">
                <a href="#admin-operation-logs/" class="a">{% trans "Admin Operation Logs" %}</a>
            </li>
            <li class="tab ui-state-active">
                <a href="#admin-login-logs/" class="a">{% trans "Admin Login Logs" %}</a>
            </li>
        </ul>
    </div>
    <span class="loading-icon loading-tip"></span>
    <table class="hide">
        <thead>
            <tr>
                <th width="35%">{% trans "Email" %}</th>
                <th width="25%">{% trans "IP" %}</th>
                <th width="15%">{% trans "Status" %}</th>
                <th width="25%">{% trans "Time" %}</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div id="paginator">
        <a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
        <a class="next js-next hide" href="#">{% trans "Next" %}</a>
    </div>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No Admin Login Logs" %}</h2>
    </div>
</script>

<script type="text/template" id="admin-login-log-item-tmpl">
    <td><a href="<%= admin_user_url %>"><%- email %></a></td>
    <td><%= login_ip %></td>
    <td>
    <% if (login_success) { %>
    {% trans "Success" %}
    <% } else { %>
    {% trans "Failed" %}
    <% } %>
    </td>
    <td><time title="<%- time %>"><%- time_from_now %></time></td>
</script>

{# address book #}
<script type="text/template" id="address-book-tmpl">
    <div class="hd ovhd">
        <h3 class="fleft">{% trans "Departments" context "address book" %}</h3>
        <div class="fright">
            <button class="btn-white js-add-group">{% trans "New Department" %}</button>
        </div>
    </div>
    <span class="loading-icon loading-tip"></span>
    <table>
        <thead>
            <tr>
                <th width="40%">{% trans "Name" %}</th>
                <th width="25%">{% trans "Created At" %}</th>
                <th width="20%">{% trans "Quota" %}</th>
                <th width="15%"><!--Operations--></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div class="empty-tips hide">
        <h2 class="alc">{% trans "No departments" %}</h2>
    </div>
    <p class="error error-tip hide"></p>
</script>
<script type="text/template" id="address-book-group-tmpl">
    <div class="hd">
        <h3 class="group-path"></h3>
    </div>
    <span class="loading-icon loading-tip"></span>
    <div class="groups">
        <div class="small-hd">
            <h4 class="small-hd-heading">{% trans "Sub-departments" %}</h4>
            <button class="btn-white js-add-group">{% trans "New Sub-department" %}</button>
        </div>
        <table class="hide">
            <thead>
                <tr>
                    <th width="40%">{% trans "Name" %}</th>
                    <th width="25%">{% trans "Created At" %}</th>
                    <th width="25%">{% trans "Quota" %}</th>
                    <th width="10%"><!--Operations--></th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <p class="empty-tip hide">{% trans "No sub-departments" %}</p>
    </div>
    <div class="members">
        <div class="small-hd">
            <h4 class="small-hd-heading">{% trans "Members" %}</h4>
            <button class="btn-white js-add-member">{% trans "Add Member" %}</button>
        </div>
        <table class="hide">
            <thead>
                <tr>
                    <th width="5%"></th>
                    <th width="25%">{% trans "Name" %}</th>
                    <th width="35%">{% trans "Email" %}</th>
                    <th width="25%">{% trans "Role" %}</th>
                    <th width="10%"><!--Operations--></th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <p class="empty-tip hide">{% trans "No members" %}</p>
    </div>
    <div class="libraries">
        <div class="small-hd">
            <h4 class="small-hd-heading">{% trans "Libraries" %}</h4>
            <button class="btn-white js-add-library">{% trans "New Library" %}</button>
        </div>
        <table class="hide">
            <thead>
                <tr>
                    <th width="5%"></th>
                    <th width="55%">{% trans "Name" %}</th>
                    <th width="30%">{% trans "Size" %}</th>
                    <th width="10%"><!--Operations--></th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <p class="empty-tip hide">{% trans "No libraries" %}</p>
    </div>
    <p class="error error-tip hide"></p>
</script>
<script type="text/template" id="address-book-group-path-tmpl">
    <a href="#address-book/" class="normal">{% trans "Departments" context "address book" %}</a>
    <span class="path-split">/</span>
    <% for (var i = 0,len = ancestor_groups.length; i < len; i++) { %>
    <a href="#address-book/groups/<%= ancestor_groups[i].id %>/" class="normal"><%- ancestor_groups[i].name %></a>
    <span class="path-split">/</span>
    <% } %>
    <%- name %>
</script>
<script type="text/template" id="address-book-group-item-tmpl">
    <td><a href="{{ SITE_ROOT }}sysadmin/#address-book/groups/<%= id %>/"><%- name %></a></td>
    <td><time title="<%= time %>"><%= time_from_now %></time></td>
    <td>
        <span <% if (quota_error) { %>class="error"<% } %>><%= quota_shown %></span>
        <span title="{% trans "Edit Quota" %}" class="quota-edit-icon sf2-icon-edit op-icon vh"></span>
    </td>
    <td>
        <a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
    </td>
</script>
<script type="text/template" id="address-book-group-add-form-tmpl">
    <form id="group-add-form" action="" method="post" class="hide">{% csrf_token %}
        <h3 id="dialogTitle"><%= title %></h3>
        <label for="group-name">{% trans "Name" %}</label><br />
        <input type="text" name="group_name" value="" class="input" id="group-name" /><br />
        <p class="error hide"></p>
        <input type="submit" class="submit" value="{% trans "Submit" %}" />
    </form>
</script>
<script type="text/template" id="address-book-group-quota-set-form-tmpl">
<form id="set-quota-form" method="post" action="" class="hide">{% csrf_token %}
    <h3>{% trans "Set quota" %}</h3>
    <input type="text" name="quota" class="input" /> MB
    <p class="tip">
        <span>{% trans "An integer that is greater than 0 or equal to -2." %}</span><br />
        <span>{% trans "Tip: -2 means no limit." %}</span>
    </p>
    <p class="error hide"></p>
    <input type="submit" value="{% trans "Submit" %}" class="submit" />
</form>
</script>
<script type="text/template" id="address-book-group-library-item-tmpl">
    <td>
        <img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
    </td>
    <td>
        <% if (enable_sys_admin_view_repo && is_pro && !encrypted) { %>
        <a href="#libs/<%= repo_id %>/"><%- name %></a>
        <% } else { %>
        <%- name %>
        <% } %>
    </td>
    <td><%- formatted_size %></td>
    <td>
        <a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
    </td>
</script>
<script type="text/template" id="address-book-library-add-form-tmpl">
    <form id="library-add-form" action="" method="post" class="hide">{% csrf_token %}
        <h3 id="dialogTitle">{% trans "New Library" %}</h3>
        <label for="library-name">{% trans "Name" %}</label><br />
        <input type="text" name="library_name" value="" class="input" id="library-name" /><br />
        <p class="error hide"></p>
        <input type="submit" class="submit" value="{% trans "Submit" %}" />
    </form>
</script>
